package top.jle.wx.proxy.feign;

import com.alibaba.fastjson2.JSONObject;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

@FeignClient(url = "https://api.weixin.qq.com",name="basic")
public interface BasicAPIFeign {
    /**
     * 获取微信Access_Token
     * @param appId
     * @param secret
     * @return
     */
    @GetMapping("/cgi-bin/token?grant_type=client_credential")
    JSONObject getAccessToken(@RequestParam("appid") String appId, @RequestParam("secret") String secret);

    /**
     * 获取微信JS-SDK API_Ticket
     * @param accessToken
     * @return
     */
    @GetMapping("/cgi-bin/ticket/getticket?type=jsapi")
    JSONObject getJSAPITicket();


    /**
     * 根据授权Code获取未关注公众号的粉丝信息 信息完整度基于授权类型 若为snsapi_base则只有openid
     * @param appId
     * @param secret
     * @param code
     * @return
     */
    @GetMapping("/sns/oauth2/access_token?grant_type=authorization_code")
    JSONObject loadSnsInfo(@RequestParam("appid") String appId,@RequestParam("secret") String secret,@RequestParam("code") String code);

    /**
     * 根据授权信息拉取用户信息 仅限授权Scope为snsapi_userinfo时有效
     * @param accessToken
     * @param openid
     * @return
     */
    @GetMapping("/sns/userinfo?lang=zh_CN")
    JSONObject loadUserInfoBySNS(@RequestParam("access_token") String accessToken,@RequestParam("openid") String openid);

    /**
     * 小程序Code2Session接口
     * @param jsCode
     * @return
     */
    @PostMapping("/sns/jscode2session?grant_type=authorization_code")
    JSONObject jsCode2Session(@RequestParam("js_code") String jsCode);
}
